import sys
import pikepdf

if len(sys.argv) != 4:
    print('Usage: pdf_decrypt.py input.pdf output.pdf password')
    sys.exit(1)

input_path, output_path, password = sys.argv[1:4]

try:
    pdf = pikepdf.open(input_path, password=password)
    pdf.save(output_path)
    pdf.close()
    sys.exit(0)
except Exception as e:
    sys.exit(2) 